﻿IF object_id(N'dbo.TabExtMailSendBuffer', 'U') IS NULL
BEGIN
    CREATE TABLE [dbo].[TabExtMailSendBuffer] (
        [MailID]         numeric(18,0) NOT NULL identity(1, 1),
        [UserID]         numeric(18,0) NOT NULL,
        [MailSendDate]   datetime      NOT NULL,
        [MailSendLevel]  smallint      NOT NULL,
        [MailToAddr]     nvarchar(30)  COLLATE Chinese_PRC_CI_AS NOT NULL,
        [MailSubject]    nvarchar(30)  COLLATE Chinese_PRC_CI_AS NOT NULL,
        [MailText]       nvarchar(300) COLLATE Chinese_PRC_CI_AS NOT NULL,
        [MailAttachFile] nvarchar(300) COLLATE Chinese_PRC_CI_AS NULL,
        [MailCcToAddr]   nvarchar(300) COLLATE Chinese_PRC_CI_AS NULL,
        [MailBccToAddr]  nvarchar(300) COLLATE Chinese_PRC_CI_AS NULL,
        [MailImportance] int           NOT NULL,
        [MailSendNumber] int           NOT NULL CONSTRAINT [DF_TabExtMailSendBuffer_MailSendNumber] default(((0))),

        CONSTRAINT [PK_tabMailSendBuffer] PRIMARY KEY CLUSTERED ([MailID] asc),
        CONSTRAINT [FK_TabMailSend_TabAccountIndex] FOREIGN KEY ([UserID]) REFERENCES [dbo].[TabAccountIndex] ([UserID]) ON DELETE CASCADE ON UPDATE CASCADE
    );
END
GO
